<template>
  <div>
    <!-- 回显填写的信息 -->
    <el-form
      disabled
      label-position="right"
      label-width="160px"
      :model="formData"
      :inline="true"
    >
      <el-form-item :rules="[{ required: true }]" :label="$t('page.formula')">
        <el-radio-group v-model="formData.formulaValue">
          <el-radio :label="0">{{ $t("page.default") }}</el-radio>
          <el-radio :label="1">{{ $t("page.newFormula") }}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        :rules="[{ required: true }]"
        :label="$t('page.molecular')+'（Da）：'"
      >
        <el-input type="number" class="input" v-model="formData.mole" style="width: 200px;"> </el-input>
      </el-form-item>
      <el-form-item
        :rules="[{ required: true }]"
        :label="$t('page.zeroProcess')"
      >
        <el-radio v-model="formData.zero" label='0'>{{$t('page.zero')}}</el-radio>
        <el-radio v-model="formData.zero" label="1">{{$t('page.noZero')}}</el-radio>
      </el-form-item>
      <el-form-item
        :rules="[{ required: true }]"
        :label="$t('page.zeroProcess')"
      >
        <el-radio v-model="formData.fitting" :label='0'>{{$t('page.default')}}</el-radio>
        <el-radio v-model="formData.fitting" :label="1">{{$t('page.optimization')}}</el-radio>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  props: {
    otherParams: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      formData: {
        formulaValue: 0,
        mole: '',
        zero: "0",
        fitting: 0,
      },
    };
  },
  watch: {
    otherParams: {
      handler(val) {
        if (!val || !val.hasOwnProperty("mole")) return;
        this.$nextTick(() => {
          this.formData.mole = val.mole || "";
          this.formData.formulaValue = +val.formulas;
          this.formData.zero = val.zero;
          this.formData.fitting = +val.fit_opt;
          this.$forceUpdate();
        });
      },
      deep: true,
    },
  },
};
</script>
